<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>并发与并行：现代计算的双重奏</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 100%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 8px;
            margin-top: 3px;
            font-weight: 700;
            color: #667eea;
        }
        
        .icon-box {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 15px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .timeline-item {
            position: relative;
            padding-left: 40px;
            margin-bottom: 30px;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 10px;
            top: 5px;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #667eea;
        }
        
        .timeline-item::after {
            content: '';
            position: absolute;
            left: 14px;
            top: 15px;
            width: 2px;
            height: calc(100% + 20px);
            background: #e0e0e0;
        }
        
        .timeline-item:last-child::after {
            display: none;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                并发与并行
            </h1>
            <p class="text-xl md:text-2xl font-light opacity-90 mb-8">
                现代计算的双重奏
            </p>
            <div class="flex justify-center space-x-8 text-lg">
                <div class="flex items-center">
                    <i class="fas fa-layer-group mr-2"></i>
                    <span>多任务处理</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-microchip mr-2"></i>
                    <span>性能优化</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-sync-alt mr-2"></i>
                    <span>系统设计</span>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        
        <!-- Introduction -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="first-letter">并</span>发（Concurrency）和并行（Parallelism）是计算机科学中描述多任务处理的两个概念，它们虽然相关，但有着不同的意义和应用场景。这两者在现代计算机系统中往往是互补的：并发用于管理任务和提高系统响应能力，并行用于加速计算过程。
            </p>
        </div>

        <!-- Visual Comparison -->
        <div class="grid md:grid-cols-2 gap-8 mb-12">
            <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                <div class="icon-box">
                    <i class="fas fa-tasks"></i>
                </div>
                <h2 class="text-3xl font-bold mb-4 text-gradient">并发 Concurrency</h2>
                <p class="text-gray-600 mb-4">逻辑上的同时进行</p>
                <div class="space-y-3">
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-purple-500 mt-1 mr-3"></i>
                        <span class="text-gray-700">多个任务交替执行</span>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-purple-500 mt-1 mr-3"></i>
                        <span class="text-gray-700">提高系统响应能力</span>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-purple-500 mt-1 mr-3"></i>
                        <span class="text-gray-700">优化资源利用率</span>
                    </div>
                </div>
            </div>
            
            <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                <div class="icon-box">
                    <i class="fas fa-rocket"></i>
                </div>
                <h2 class="text-3xl font-bold mb-4 text-gradient">并行 Parallelism</h2>
                <p class="text-gray-600 mb-4">物理上的同时执行</p>
                <div class="space-y-3">
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-purple-500 mt-1 mr-3"></i>
                        <span class="text-gray-700">多个任务真正同时运行</span>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-purple-500 mt-1 mr-3"></i>
                        <span class="text-gray-700">提高计算性能</span>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-purple-500 mt-1 mr-3"></i>
                        <span class="text-gray-700">加速处理过程</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Concept Visualization -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold mb-6 section-title">概念关系图</h2>
            <div class="mermaid">
                graph TD
                    A[多任务处理] --> B[并发 Concurrency]
                    A --> C[并行 Parallelism]
                    B --> D[时间片轮转]
                    B --> E[任务调度]
                    B --> F[单核处理器]
                    C --> G[同时执行]
                    C --> H[多核处理器]
                    C --> I[分布式计算]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- Detailed Comparison -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold mb-8 section-title">深入对比</h2>
            
            <div class="space-y-8">
                <!-- 定义对比 -->
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-purple-50 rounded-xl p-6">
                        <h3 class="text-xl font-bold mb-3 text-purple-700">
                            <i class="fas fa-book mr-2"></i>并发的定义
                        </h3>
                        <p class="text-gray-700 leading-relaxed">
                            并发是指在同一时间段内，多个任务在逻辑上同时进行。并发并不要求任务实际同时执行，而是它们可以在不同的时间片段中交替进行。并发主要关注任务的调度和管理，解决如何在有限的资源上高效地处理多个任务。
                        </p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <p class="text-sm text-gray-600">
                                <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                                <strong>例子：</strong>在单核处理器上，操作系统通过时间片轮转的方式让多个任务看起来是同时进行的。
                            </p>
                        </div>
                    </div>
                    
                    <div class="bg-indigo-50 rounded-xl p-6">
                        <h3 class="text-xl font-bold mb-3 text-indigo-700">
                            <i class="fas fa-book mr-2"></i>并行的定义
                        </h3>
                        <p class="text-gray-700 leading-relaxed">
                            并行是指多个任务在物理上同时执行。并行要求任务可以真正同时进行，通常需要多核处理器或多台计算机。并行关注的是如何在多个处理单元上同时执行任务，以提高计算效率。
                        </p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <p class="text-sm text-gray-600">
                                <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                                <strong>例子：</strong>在多核处理器上，多个核心可以同时执行不同的任务或同一任务的不同部分。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 目标对比 -->
                <div class="mt-8">
                    <h3 class="text-2xl font-bold mb-6 text-gray-800">
                        <i class="fas fa-bullseye mr-3 text-purple-600"></i>核心目标
                    </h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="border-l-4 border-purple-500 pl-6">
                            <h4 class="font-bold text-lg mb-2">并发的目标</h4>
                            <p class="text-gray-700">
                                提高系统的响应能力和资源利用率，通过合理的任务调度和切换来管理多个任务。关注如何有效地管理多个任务，确保系统能够处理多个任务而不会因为一个任务的延迟影响到其他任务。
                            </p>
                        </div>
                        <div class="border-l-4 border-indigo-500 pl-6">
                            <h4 class="font-bold text-lg mb-2">并行的目标</h4>
                            <p class="text-gray-700">
                                提高计算性能和效率，通过同时执行多个任务来加速处理速度。关注如何利用硬件资源（如多核处理器）来同时执行任务，从而减少总的计算时间。
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Implementation Methods -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold mb-8 section-title">实现方式</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-cogs text-purple-600 mr-3"></i>
                        并发的实现
                    </h3>
                    <div class="space-y-3">
                        <div class="timeline-item">
                            <p class="text-gray-700">依赖于操作系统的调度机制</p>
                        </div>
                        <div class="timeline-item">
                            <p class="text-gray-700">线程或